//go:build wireinject

package main

import (
	"github.com/google/wire"
	"go-admin/server/internal/events/log"
	"go-admin/server/internal/repository"
	"go-admin/server/internal/repository/cache"
	"go-admin/server/internal/repository/dao"
	"go-admin/server/internal/service"
	"go-admin/server/internal/web"
	"go-admin/server/internal/web/jwt"
	"go-admin/server/ioc"
	"go-admin/server/ioc/grpc"
)

var iocSet = wire.NewSet(
	ioc.InitRedis,
	ioc.InitDB,
	ioc.InitEtcd,
	//ioc.InitEtcdClient,
	ioc.InitConsul,
	ioc.InitKafka,
	ioc.NewSyncProducer,
	ioc.NewConsumers,
	ioc.InitAppLogger,
	ioc.InitGormLogger,
	ioc.InitHttpLogger,
	ioc.InitEs,
	ioc.InitGin,
	ioc.InitMiddleware,
	ioc.InitTencentSms,
)
var menuSet = wire.NewSet(
	dao.NewMenuDao,
	service.NewMenuService,
	repository.NewMenuRepository,
	web.NewMenuHander,
)
var cacheSet = wire.NewSet(
	cache.NewCodeCache,
)

var remoteSet = wire.NewSet(
// dao2.NewFileDao,
// repository2.NewFileRepository,
// service2.NewFileService,
)

// func InitWebServer(*conf.SettingConfig) *gin.Engine {
func InitWebServer() *App {
	wire.Build(
		iocSet,
		menuSet,
		cacheSet,
		grpc.InitFileGrpcClientForConsul,
		grpc.InitLogGrpcClientForConsul,

		dao.NewRbacDao, dao.NewAdminDao, dao.NewPackDao,

		repository.NewRbacRepository, repository.NewAdminRepository, repository.NewPackRepository,

		service.NewRbacService, service.NewAdminServer, service.NewSettingService, service.NewPackServer,

		web.NewRbacHandler, web.NewAdminHandler, web.NewSettingHandler, web.NewFileHandler, web.NewPackHandler, web.NewLogHandler,

		service.NewCodeService, repository.NewCodeRepository,

		//consumer
		log.NewInteractiveReadEventGormLogConsumer,

		//producer
		jwt.NewJwtHandler,
		wire.Struct(new(App), "*"),
	)
	return new(App)
}
